﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_UPDMS_REF_SHOP_Get_Shop_Info_List')
	BEGIN
		DROP Procedure usp_UPDMS_REF_SHOP_Get_Shop_Info_List
	END
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
/******************************************************************************
**	Name : usp_UPDMS_REF_SHOP_Get_Shop_Info_List
**	Desc : 활력업소를 조회한다.
**	Test Exec Query : Exec usp_UPDMS_REF_SHOP_Get_Shop_Info_List 'Y'
**	Called by : Ref_Dac_UPDMS_REF_SHOP.cs
**	Program ID : Ref1011m, Ref1012m
**	Auth : 송시명
**	Date : 2013-04-19
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:		Description:
**	--------	--------	---------------------------------------
**			
*******************************************************************************/
CREATE PROC [dbo].[usp_UPDMS_REF_SHOP_Get_Shop_Info_List]
@ls_favorite_yn nvarchar(1)
AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON

DECLARE @favorite_yn nvarchar(1)
IF @ls_favorite_yn = 'Y' OR @ls_favorite_yn = 'N'
BEGIN
    SET @favorite_yn = @ls_favorite_yn
END
ELSE
BEGIN
    SET @favorite_yn = ''
END

SELECT Shop_Nm,
       Shop_Id,
       CASE (dbo.ufn_UPDMS_Get_Setting_Value('REF_Opt_01'))
            WHEN Shop_Id THEN '0'
            ELSE '1'
       END View_Order
  FROM UPDMS_REF_SHOP WITH(NOLOCK)
 WHERE Favorite_Yn LIKE @favorite_yn + '%'
 ORDER BY View_Order, Favorite_Yn DESC, Shop_Nm

GO